package com.dddd.blog.blogadmin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dddd.blog.api.admin.pojo.Admin;
import com.dddd.blog.blogadmin.mapper.AdminMapper;
import com.dddd.blog.blogadmin.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dddd
 * @since 2022-03-08
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {

    @Autowired
    private AdminMapper adminMapper;


    @Override
    public Admin getAdmin(String name, String password){

        QueryWrapper<Admin> wrapper = new QueryWrapper();

        wrapper.eq("name",name);

        Admin admin = adminMapper.selectOne(wrapper);

        return admin;
    }

    @Override
    public Admin getAdminByName(String username) {

        QueryWrapper<Admin> wrapper = new QueryWrapper();

        wrapper.eq("name",username);

        return adminMapper.selectOne(wrapper);
    }
}
